import { request } from "../request";
import type {
  CaptchaResult,
  LoginOption,
  LoginResult,
  vendorData,
  userData,
  partnerData,
  bindSupplierOption,
  sumPurchaseOrderOption
} from "./model";

// 获取验证码
export function captcha() {
  return request<CaptchaResult>({
    url: "/captcha",
  });
}

// 登录
export function login(data: LoginOption) {
  return request<LoginResult>({
    url: "/login",
    params: data,
  });
}


//获取供应商信息
export function getVendorData() {
  return request<vendorData[]>({
    url: "/register/vendoridList",
  });
}

//添加人员
export function insertUser(data: userData) {
  return request({
    url: "/register/registerAdministrator",
    params:data,
  });
}

//编辑人员信息
export function upUser(data:userData) {
  return request({
    url: "/register/updateAdministrator",
    params:data,
  });
}

//删除人员信息
export function deleteUser(id:string) {
  return request({
    url: '/register/deleteAdministrator',
    params: { id }
  })
}

//添加合作商
export function insertPartner(data:partnerData) {
  return request({
    url: '/register/registerUser',
    params:data,
  })
}

//编辑合作商信息
export function upPartner(data:partnerData) {
  return request({
    url: "/register/updateUser",
    params:data,
  });
}

//删除合作商信息
export function deletePartner(id:string) {
  return request({
    url: '/register/deleteUser',
    params: { id }
  })
}


//获取全部学校信息
export function getSchoolList() {
  return request({
    url: '/productSupplier/getSchoolList',
   
  })
}

//获取全部大类信息

export function queryAllGoodsClass() {
  return request({
    url: '/productSupplier/queryAllGoodsClass',
   
  })
}


//获取当前学校商品绑定的供货商信息（Shopid代表学校）
export function getProdSupBindInfo(cShopId:string) {
  return request({
    url: 'productSupplier/getProdSupBindInfo',
    params:cShopId
   
  })
}

//获取当前主供应商id下合作商信息(cShopid代表主供应商)
export function getPartnerInformationInfo(mainSupplierId) {
  console.log(mainSupplierId)
  return request({
    url: '/productSupplier/getPartnerInformationInfo',
    params:mainSupplierId
   
  })
}
//学校商品大类绑定供应商
export function bindSupplier(data:bindSupplierOption) {
  return request({
    url: '/productSupplier/bindSupplier',
    params:data
   
  })
}

//汇总采购单
export function sumPurchaseOrder(data:sumPurchaseOrderOption){
  return request({
    url: '/purchaseSummary',
    params:data
   
  })
}

//查询汇总列表-按商品大类
export function querySummaryListByCategory(data:sumPurchaseOrderOption){
  return request({
    url: '/querySummaryListByCategory',
    params:data
   
  })
}


//查询汇总列表-按学校
export function querySummaryListBySchool(data:sumPurchaseOrderOption){
  return request({
    url: '/querySummaryListBySchool',
    params:data
   
  })
}

//分单操作
export function singleOrderOption(username:any){
  return request({
    url: '/divideOrder/insertDivideOrderList',
    params:username
   
  })
}

//获取分单详情
export function queryDivideOrderList(code:any){
  return request({
    url: '/divideOrder/queryDivideOrderList',
    params:code
   
  })
}

//配送
export function divideOrder(code:any){
  return request({
    url: '/divideOrder/updateStatus',
    params:code
   
  })
}

//导出
export function exportlist(code:any){
  return request({
    url: '/divideOrder/export/exportDividerOrderList',
    params:code
   
  })
}